﻿#include "Dx2ShaderAndLayoutManager.h"

void Dx2ShaderAndLayoutManager::BuildShaderAndLayout()
{
	const D3D_SHADER_MACRO defines[] =
	{
		"FOG","1",
		NULL, NULL
	};
    
    const D3D_SHADER_MACRO alphaTestDefines[] =
	{
		"FOG","1",
		"ALPHA_TEST", "1",
		NULL, NULL
	};

	const D3D_SHADER_MACRO waveDefines[] =
	{
		"DISPLACEMENT_MAP", "1",
		NULL, NULL
	};

	mShaders["standardVS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Default.hlsl",nullptr,"VS","vs_5_0");
	mShaders["opaquePS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Default.hlsl",defines,"PS","ps_5_0");
	
	mShaders["wavesVS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Default.hlsl",waveDefines,"VS","vs_5_0");

	mShaders["alphaTestedPS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Default.hlsl",alphaTestDefines,"PS","ps_5_0");

	mShaders["treeSpriteVS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\TreeSprite.hlsl",nullptr,"VS","vs_5_0");
	mShaders["treeSpriteGS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\TreeSprite.hlsl",nullptr,"GS","gs_5_0");
	mShaders["treeSpritePS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\TreeSprite.hlsl",alphaTestDefines,"PS","ps_5_0");

	mShaders["wavesUpdateCS"] =d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\WaveSim.hlsl",nullptr,"UpdateWavesCS","cs_5_0");
	mShaders["wavesDisturbCS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\WaveSim.hlsl",nullptr,"DisturbWavesCS","cs_5_0");

	mShaders["vecAddCS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\VecAdd.hlsl",nullptr,"CS","cs_5_0");
	
	mShaders["horzBlurCS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Blur.hlsl",nullptr,"HorzBlurCS","cs_5_0");
	mShaders["vertBlurCS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Blur.hlsl",nullptr,"VertBlurCS","cs_5_0");

	mShaders["compositeVS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Composite.hlsl",nullptr,"VS","vs_5_0");
	mShaders["compositePS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Composite.hlsl",nullptr,"PS","ps_5_0");

	mShaders["tessVS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Tessellation.hlsl",nullptr,"VS","vs_5_0");
	mShaders["tessHS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Tessellation.hlsl",nullptr,"HS","hs_5_0");
	mShaders["tessDS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Tessellation.hlsl",nullptr,"DS","ds_5_0");
	mShaders["tessPS"] = d3dUtil::CompileShader(L"..\\..\\Res\\Shaders\\Tessellation.hlsl",nullptr,"PS","ps_5_0");

	mInputLayout =
		{
			{
				"POSITION",0,DXGI_FORMAT_R32G32B32_FLOAT,0,0,D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA,0
			},
			{
				"NORMAL",0,DXGI_FORMAT_R32G32B32_FLOAT,0,12,D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA,0
			},
			{
				"TEXCOORD",0,DXGI_FORMAT_R32G32_FLOAT,0,24,D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA,0
			}
		};

	mTreeSpriteInputLayout =
		{
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
			{ "SIZE", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
		};

	mTessellationInputLayout =
	{
		{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }
	};
}



const std::vector<D3D12_INPUT_ELEMENT_DESC>& Dx2ShaderAndLayoutManager::GetInputLayout() const
{
	return  mInputLayout;
}

const std::vector<D3D12_INPUT_ELEMENT_DESC>& Dx2ShaderAndLayoutManager::GetTreeInputLayout() const
{
	return  mTreeSpriteInputLayout;
}

const std::vector<D3D12_INPUT_ELEMENT_DESC>& Dx2ShaderAndLayoutManager::GetTessellationLayout() const
{
	return  mTessellationInputLayout;
}




